﻿<UserControl
    x:Class="Markup.Programming.Samples.ForLoops"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:p="http://markupprogramming.codeplex.com/markup/programming"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    Height="300" Width="300">
    <Grid>
        <StackPanel>
            <Button Content="Standard For">
                <p:Attached.Operations>
                    <p:EventHandler Path="Click">
                        <p:For Var="$i" TypePath="[Int32]">
                            <p:For.Value>
                                <p:Path>0</p:Path>
                            </p:For.Value>
                            <p:For.While>
                                <p:Path>$i @lt 3</p:Path>
                            </p:For.While>
                            <p:For.Next>
                                <p:Path>$i++</p:Path>
                            </p:For.Next>
                            <p:Call Path="[MessageBox].Show">
                                <p:Call Path="[String].Format">
                                    <p:Path>'i = {0}'</p:Path>
                                    <p:Path>$i</p:Path>
                                </p:Call>
                            </p:Call>
                        </p:For>
                    </p:EventHandler>
                </p:Attached.Operations>
            </Button>
            <Button Content="Simplied For">
                <p:Attached.Operations>
                    <p:EventHandler Path="Click">
                        <p:For Var="$i" Value="0" UpperLimit="3" Increment="1">
                            <p:Call Path="[MessageBox].Show">
                                <p:Call Path="[String].Format">
                                    <p:Path>'i = {0}'</p:Path>
                                    <p:Path>$i</p:Path>
                                </p:Call>
                            </p:Call>
                        </p:For>
                    </p:EventHandler>
                </p:Attached.Operations>
            </Button>
        </StackPanel>
    </Grid>
</UserControl>
